<%-- 
    Document   : index
    Created on : 2020-4-17, 10:25:10
    Author     : zhang
--%>

<%@page import="java.util.List"%>
<%@page import="entity.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1 width="100px">BookStore</h1>
        
        
            <div style="position:absolute;right: 20px;top:10px">
                <%
                    if(session.getAttribute("isLogin")==null){
                %>
                <a href="Login.jsp">登录</a>/<a href="Register.jsp">注册</a><br>
                <a href="AdminLogin.jsp">管理员登录</a>
                <%
                    }else{
                        String name=(String)session.getAttribute("username");
                    
                %>
                您好，<a href="Member.jsp?name=<%=name%>"><%=name%></a><br>
                <a href="los">退出登录</a>
                <%
                    }
                %>
            </div>
            
            
        <form action="gbbn">
            <input type="text" name="keyword">&nbsp;&nbsp;
            <button>搜索</button>
        </form>
            
            <br>
            <a href="gbbn?keyword=">查看图书列表</a>
        <br>
        <hr>
        <%
            if(session.getAttribute("isLogin")==null){
        %>
        <h1>最新图书</h1>
        <div>
        <%
            List<Book> list=(List<Book>)request.getAttribute("bookList");
            for(int i=list.size()-1;i>=0;i--){
        %>
        <a href="gbbi?id=<%=list.get(i).getId()%>">
                <div style="width: 200px;height:300px;border:1px solid #000">
                    <img src="img/<%=list.get(i).getCover()%>" width="200px" height="300px" alt="<%=list.get(i).getBookName()%>">
                </div>
                <p><%=list.get(i).getBookName()%></p>
            </a>
            <%
                }
            %>
        </div>
        <%
            }
            else{
        %>
        <h1>推荐图书</h1>
        <div>
        <%
            List<Book> list=(List<Book>)request.getAttribute("likelist");
            for(int i=0;i<=list.size()-1;i++){
        %>
        <a href="gbbi?id=<%=list.get(i).getId()%>">
                <div style="width: 200px;height:300px;border:1px solid #000">
                    <img src="img/<%=list.get(i).getCover()%>" width="200px" height="300px" alt="<%=list.get(i).getBookName()%>">
                </div>
                <p><%=list.get(i).getBookName()%></p>
            </a>
            <%
                }
            %>
        </div>
        <h1>最新图书</h1>
        <div>
        <%
            List<Book> list1=(List<Book>)request.getAttribute("bookList");
            for(int i=list1.size()-1;i>=0;i--){
        %>
        <a href="gbbi?id=<%=list1.get(i).getId()%>">
                <div style="width: 200px;height:300px;border:1px solid #000">
                    <img src="img/<%=list1.get(i).getCover()%>" width="200px" height="300px" alt="<%=list1.get(i).getBookName()%>">
                </div>
                <p><%=list1.get(i).getBookName()%></p>
            </a>
            <%
                }
            %>
        </div>
        <%
            }
        %>
        
    </body>
</html>
